﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using com.dz.ct.common;
using com.dz.ct.components;

namespace com.dz.ct.business
{
    public class ComManager
    {
        #region 不同程序集反射

        private static object CreateObject(string path, string TypeName)
        {
            object obj = null;
            try
            {
                obj = Assembly.Load(path).CreateInstance(TypeName);

            }
            catch (System.Exception ex)
            {
                LogHelper.Error("反射获取对象失败" + ex.ToString());
            }

            return obj;
        }

        /// <summary>
        /// 创建网络访问接口实例
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static IBigSiteObject CreateBigSiteObj(string i_com_name)
        {
            //从程序集创建对象实例
            i_com_name = i_com_name.Replace("-", "_");
            i_com_name = "com.dz.ct.components.BigSite." + i_com_name + ".BigSiteObject";
            object objType = CreateObject("ct-2", i_com_name);
            return (IBigSiteObject)objType;
        }


        /// <summary>
        /// 创建网络访问接口实例
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static IBigSiteObject CreateSmallSiteObj(string i_com_name)
        {
            //从程序集创建对象实例
            i_com_name = i_com_name.Replace("-", "_");
            i_com_name = "com.dz.ct.components.SmallSite." + i_com_name + ".SmallSiteObject";
            object objType = CreateObject("ct-2", i_com_name);
            return (IBigSiteObject)objType;
        }


        #endregion
    }
}
